from pprint import pprint

from django.http import HttpResponse
from django.shortcuts import render
from django.views import View

from goods.models import GoodsChannel

from goods.models import GoodsCategory

from index.models import ContentCategory

from utils.category import category


# Create your views here.
class IndexView(View):
    def get(self, request):
        # 分类展示
        categories_dict = category()
        # 轮播图
        category_all = {}
        content_category = ContentCategory.objects.all()
        for contents in content_category:
            category_all[contents.key] = contents.content_set.filter(status=True).order_by("sequence")
        print(category_all)
        context = {
            'categories': categories_dict,
            'category_all': category_all
        }

        return render(request, "index.html", context)
